package face.pay.web.terminal;

import face.pay.common.enterprise.service.IterminalBaseService;
import face.pay.entity.TerminalInfo;
import face.pay.entity.UserInfo;
import face.pay.security.annotation.CurrentUser;
import face.pay.util.ResultMessage;
import face.pay.util.page.PageData;
import face.pay.util.page.PageParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.jws.WebParam;

/**
 * @Auther: zkj
 * @Date: 2019/8/14 15:26
 * @Description:代理商 对商家设备的管理
 */
@Controller
@RequestMapping("/agency_mch_terminal")
public class AgencyMchTerminalController {

    @Autowired
    private IterminalBaseService iterminalBaseService;

    /**
     * 代理商下面所有的设备
     * @return
     */
    @RequestMapping("/list")
    public String manager(Integer userId, Model model){
        model.addAttribute("userId",userId);
        return  "agency/mch_terminal_list";
    }

    /**
     * 设备修改
     * @param terminalInfo
     * @param loginUser
     * @return
     */
    @ResponseBody
    @RequestMapping("/edit")
    public ResultMessage edit(TerminalInfo terminalInfo, @CurrentUser UserInfo loginUser){
        return  iterminalBaseService.edit(terminalInfo,loginUser);
    }

    @ResponseBody
    @RequestMapping("/queryData")
    public PageData<TerminalInfo> queryPage(TerminalInfo terminalInfo, PageParam pageParam, @CurrentUser UserInfo loginUser){

        terminalInfo.setAgencyUserId(loginUser.getId());
        terminalInfo.setUserId(terminalInfo.getUserId());
        return  iterminalBaseService.queryPage(terminalInfo,pageParam,loginUser);
    }
}
